home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / SYS_TOOL / MULTI020 / MPKBD.PAS < prev    next >
Pascal/Delphi Source File  |  1993-09-07  |  1KB  |  46 lines

  1. unit MPKbd;
  2. { Provide client which puts input from the keyboard into a pipe }
  3. interface
  4. uses crt, multi, mpipes;
  5.  
  6. procedure AttachKbdTask(m : pPipe);
  7.   { Attach a task which polls the keyboard and feeds the pressed chars
  8.     into the given pipe. That task sets #AltXPressed# if Alt-X is found
  9.     within the stream of keyboard data. }
  10.  
  11. implementation
  12.  
  13. const
  14.   keyboardthere : boolean = false;
  15.  
  16. procedure KbdInTask(var m); far;
  17. var
  18.   p : tPipe absolute m;
  19.   ch : char;
  20. begin
  21.   p.NewInputTask;
  22.   if keyboardthere then begin p.NoMoreInput; exit end;
  23.   keyboardthere := true;
  24.   t^.hasexit := true;
  25.   repeat
  26.     if keypressed then begin
  27.       ch := readkey;
  28.       if (ch = #0) then begin
  29.         ch := readkey;
  30.         if (ch = #45) or p.Put(#0) or p.Put(ch) then break
  31.       end else
  32.         if p.Put(ch) then break;
  33.     end;
  34.     if Switch then break;
  35.   until false;
  36.   p.NoMoreInput;
  37.   keyboardthere := false
  38. end;
  39.  
  40. procedure AttachKbdTask(m : pPipe);
  41. begin
  42.   Fork(KbdInTask,2048,m^{$IFDEF DEBUG},'KbdIn'{$ENDIF});
  43. end;
  44.  
  45. end.
  46.